package com.zzyl.serve.controller.member;

import java.util.List;

import com.github.pagehelper.PageInfo;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.serve.domain.Elder;
import com.zzyl.serve.dto.ElderFamilyMemberDto;
import com.zzyl.serve.dto.ElderInfoDTO;
import com.zzyl.serve.dto.UserLoginRequestDto;
import com.zzyl.serve.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.serve.service.IFamilyMemberService;

/**
 * 老人家属Controller
 * 
 * @author itheima
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属相关接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;
    /**
     * 小程序端 用户登录
     */
	@PostMapping("/login")
    @ApiOperation("小程序端 用户登录")
    public R<LoginVo> login(@RequestBody UserLoginRequestDto dto) {

        LoginVo vo = familyMemberService.login(dto);
        return R.ok(vo);
    }


    @PostMapping("/add")
    @ApiOperation("小程序端 绑定家人")
    public AjaxResult addElderMember(@RequestBody ElderInfoDTO dto) {

        familyMemberService.addElderMember(dto);
        return AjaxResult.success();
    }
    @GetMapping("/list-by-page")
    @ApiOperation(value = "查看家人列表（分页查询）")

    public R<List<ElderFamilyBindVO>> BypageselectFamilyMemberList(ElderInfoDTO dto){
        startPage();
        List<ElderFamilyBindVO> list = familyMemberService.listByPage(dto.getPageNum(), dto.getPageSize());
        return R.ok(list);
    }
    @GetMapping("/queryServiceProperties/{iotId}")
    @ApiOperation(value = "1.4 查询健康数据")
    public R<List<?>> queryServiceProperties(@PathVariable String iotId) {
        List<?> list = familyMemberService.queryServiceProperties(iotId);
        return R.ok(list);
    }
    /**
     * 1.5 按天统计查询指标数据
     * 接口地址:/member/user/queryDeviceDataListByDay
     * 请求方式:GET
     */
    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult queryDeviceDataListByDay(String iotId, String functionId, Long startTime, Long endTime) {
        return success(familyMemberService.queryDeviceDataListByDay(iotId, functionId, startTime, endTime));
    }

    /**
     * 1.6 按周统计查询指标数据
     * 接口地址:/member/user/queryDeviceDataListByWeek
     * 请求方式:GET
     */
    @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult queryDeviceDataListByWeek(String iotId, String functionId, Long startTime, Long endTime) {
        return success(familyMemberService.queryDeviceDataListByWeek(iotId, functionId, startTime, endTime));
    }










}
